package com.hongxin.nw.netty.model.analysis;

import com.hongxin.nw.netty.utils.BinaryTools;
import com.hongxin.nw.netty.utils.FieldAnalysis;
import com.hongxin.nw.netty.values.TypeIdentif;
import io.netty.buffer.ByteBuf;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

/**
 * @remark --
 * @author: GuoXiaolin
 * @date 2019/5/23 16:06
 * @Version 1.0
 * @Descibe
 */
@Slf4j
@Getter
@Setter
public class ASDUmjcna1{

    private int etype;//设备类型
    private String busiData;//充电设备实时监测数据

    private int idx = 0;
    private ByteBuf byteBuf;

    private  void subRecord() {
//        this.etype = substring(TypeIdentif.BYTE_EQUIPMENT_TYPE.getByteLength());
//        this.etype = FieldAnalysis.analysisBin(this.etype);

        int bytelength = TypeIdentif.BYTE_EQUIPMENT_TYPE.getInt();
        String pe = BinaryTools.subByteBuf(bytelength, idx, byteBuf);
        this.etype = Integer.parseInt(FieldAnalysis.analysisBin(pe));
        this.idx += bytelength;
    }
    private  void subBusiData() {
        this.busiData = "byteBuf data";
    }

    public int analysisStr(int idx, ByteBuf byteBuf) {
        this.idx = idx;
        this.byteBuf = byteBuf;
        subRecord();
        subBusiData();
        return this.idx;
    }

    @Override
    public String toString() {
        return "ASDUmjcna1{" +
                "etype='" + etype + '\'' +
                ", busiData='" + busiData + '\'' +
                '}';
    }
}
